Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(SwingSet): minor tidying extracted from #9539 #9558

Merged
merged 5 commits into from
Jun 28, 2024

Conversation

erights
Copy link
Member

@erights erights commented Jun 21, 2024

closes: #XXXX
refs: https://github.com/Agoric/agoric-sdk/pull/9539/files#r1648285867

Description

As @warner suggests at #9539 (comment) , I'm moving that change to this separate PR so we can decide separately when to merge it. It should be a pure refactor, since nothing should have been counting on the absence of the harden

Security Considerations

hardening early is better for integrity, and will catch some integrity-violating bugs (property mutations) earlier. Almost certainly no difference in this case though, but good precedent for reenforce best practices.

In fact, within the SwingSet kernel, this cannot have any effect on production under current configurations, where harden is turned off for SwingSet anyway. But at least we still have the option of turning harden on when testing, in which case we still get the bug finding benefit.

Finally, it is possible we will someday find we can afford to turn harden back on for SwingSet as a whole, in which case we get back this integrity protection for real.

PLEASE establish the habit of hardening literals before they escape whenever possible!

Scaling Considerations

none

Documentation Considerations

none

Testing Considerations

harden in SwingSet could be turned on during testing, in which case these harden calls with detect more bugs.

Upgrade Considerations

Why we pulled this out into a separate PR. See https://github.com/Agoric/agoric-sdk/pull/9539/files#r1648285867

@erights erights self-assigned this Jun 21, 2024
Copy link

cloudflare-workers-and-pages bot commented Jun 21, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 09b921c
Status: ✅  Deploy successful!
Preview URL: https://35a81364.agoric-sdk.pages.dev
Branch Preview URL: https://markm-tidy-v-v-admin.agoric-sdk.pages.dev

View logs

@erights erights requested a review from warner June 21, 2024 17:29
@erights erights marked this pull request as ready for review June 21, 2024 18:18
@warner
Copy link
Member

warner commented Jun 27, 2024

BTW, I think #9539 (comment) is the right link to the discussion about why this was pulled out of the other PR.. the original link was to lines of code being changed, which went stale when this particular edit was removed from that branch.

@warner
Copy link
Member

warner commented Jun 27, 2024

In fact, within the SwingSet kernel, this cannot have any effect on production under current configurations, where harden is turned off for SwingSet anyway. But at least we still have the option of turning harden on when testing, in which case we still get the bug finding benefit.

Huh? In what way is harden "turned off"?

From what I can tell,

knownResolutions.set(p, harden([isReject, value]));
will harden any return values from a message delivery, just before serializing the answer for syscall.resolve(). So technically this PR is a NOP just because the result of finishVatCreation() is promptly returned from createVat(), which is always invoked as E(vatAdminSvc).createVat(), i.e. as a message delivery. So the value is hardened a turn or two later, and in any case the recipient of the value is in a different vat (and their copy will be hardened by their marshal.unserialize).

We've done performance experiments where harden is replaced with a NOP, and we have test environments in which relaxDurabilityRules is set and durable objects accept non-durables in their state, but as far as I know the production liveslots uses real harden() and real durability rules.

It's certainly best practice to harden before the return, of course, and I'm all in favor of maintaining this as our required coding style. So I have no problem with the text of the change.

The only significant consideration here is to have a clear policy on when/how we make changes to code for which we don't have a clear deployment scheduled. This change to vat-vat-admin is fine (it doesn't change externally-visible behavior). It will sit on master for a while until we figure out how to safely update vat-vat-admin, and schedule an update, and roll it out.

A more interesting change, though (eg adding a new method, or relaxing some constraint), would require more attention. We should probably have a table somewhere of changes that have gone into trunk but are not yet deployed to the chain, so we can be deliberate about when+how they get deployed. And, we must be mindful in the meantime that trunk CI is testing against undeployed code, so e.g. a new vat that thinks it can use this new vat-vat-admin method, and passes in CI, must not get deployed to the chain before the vat-vat-admin upgrade. That's a bigger discussion, of course, so this note is mostly serving to convince ourselves that this particular PR does not need to wait for that bigger discussion.

@erights
Copy link
Member Author

erights commented Jun 27, 2024

https://github.com/endojs/endo/blob/master/packages/init/unsafe-fast.js sets __hardenTaming__: 'unsafe'.

which causes the fakeHarden of https://github.com/endojs/endo/blob/master/packages/ses/src/tame-harden.js to be used as harden.

So all importers of unsafe-fast.js
image

run with harden bound to

const fakeHarden = arg => arg

See
endojs/endo#1528
#7438

@erights erights added the automerge:squash Automatically squash merge label Jun 27, 2024
@mergify mergify bot merged commit 14b9af4 into master Jun 28, 2024
77 checks passed
@mergify mergify bot deleted the markm-tidy-v-v-admin branch June 28, 2024 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge technical-debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants